#pragma once

#pragma once

#include "HaSh.h"

namespace MyUnorderMap
{
	template <typename K, typename V>
	class unordered_map
	{
	public:
		struct MapOfT
		{
			const K& operator()(const pair<const K, V>& kv)
			{
				return kv.first;
			}
		};

		typedef typename/**/ hash_bucket::HashTable<K, pair<const K, V>, MapOfT>::iterator iterator;
		typedef typename/**/ hash_bucket::HashTable<K, pair<const K, V>, MapOfT>::const_iterator const_iterator;

		pair<iterator, bool> insert(const pair<const K, V>& kv)
		{
			return _ht.Insert(kv);
		}

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator begin() const
		{
			return _ht.begin();
		}
		 
		const_iterator end() const
		{
			return _ht.end();
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _ht.Insert({ key, V() });
			return ret.first->second ;
		}

		iterator find(const K& key)
		{
			return _ht.Find(key);
		}

		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		hash_bucket::HashTable<K, pair<const K, V>, MapOfT> _ht;
	};
}